package baoxiu.controller;

import baoxiu.entity.Building;
import baoxiu.service.BuildingService;
import common.util.Res;
import common.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName BuildingControllee
 * @Author mengjiafeng
 * @Date 2019/7/24 19:48
 **/
@RestController
@RequestMapping("/baoxiu/build")
public class BuildingController {

    @Autowired
    private BuildingService buildingService;

    /**
     * 获取所有楼
     * @return
     */
    @GetMapping("/findAll")
    public Result<List<Building>> selectAll(){
        List<Building> list = buildingService.list();
        return Res.makeOKRsp(list);
    }
    @PostMapping("/add")
    public Result add(Building building){
        buildingService.save(building);
        return Res.makeOKRsp("添加成功");
    }
    @DeleteMapping("/delete")
    public Result delete(String id){
        buildingService.removeById(id);
        return Res.makeOKRsp("删除成功");

    }
}
